#include "LED/led.h"
#include "UART/uart.h"
#include "PLL/pll.h"
#include "PRINT/my_printf.h"
#include "VIC/vic_reg.h"
#include "INIT/init.h"
#include "EXTI/exti.h"
#include "TIMER/timer.h"
#include "SDIO/sdio.h"
#include "PUBLIC/test.h"
#include "PUBLIC/public.h"

extern int over_flag;

void delay(uint t){
    while(t--);
}

void test(){
    u32 val, con_base;

    __asm__(
        "MRC p15, 0, %0,c0,c0, 5\n"
        "MRC p15, 4, %1,c15,c0, 0\n"
        :"=r"(val), "=r"(con_base)
        );

    printf("MPIDR: %x\r\n", val);
    printf("con_base: %x\r\n", con_base);
}

int main(){
    u32 fp, sp;

    led_init();
    exti_init();
    // timer0_init();
    // timer2_init();
    print_cpsr();
    // print_PERIPHBASE();
    // print_val("SDMMCVLKENB", 0xC00C5000);
    // print_val("SDMMCCLKGEN0L", 0xC00C5004);
    // find();

    test();
    print_val("[0xC001027C]", 0xC001027C);
    print_val("[0xC001089C]", 0xC001089C);
    print_val("[0xC0010800]", 0xC0010800);

    sdio0_init();

    __asm__(
        "mov %0, fp\n"
        "mov %1, sp\n"
        :"=r"(fp), "=r"(sp)
    );
    printf("main fp:%x sp:%x\r\n", fp, sp);

    // find(&over_flag);

    while(1){

        led1_on();
        delay(2000000);
        led1_off();
        delay(2000000);
        // printf("TCON_TIMER0: %x\r\n", TCNTO0_TIMER0);
    }

    return 0;
}
